﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace WW.NActiveRecord.Internal.Utils
{
    /// <summary>
    /// 忽略大小写比较器，可以用在字符串大小写不敏感的集合中
    /// </summary>
    internal class CaseInsensitiveComparer2 : IEqualityComparer<string> {

        /// <summary>
        /// 比较器唯一提供的实例对象
        /// </summary>
        public static IEqualityComparer<string> Default = new CaseInsensitiveComparer2();

        //私有化构造器是由于:无状态对象只需要一个Default实例即可
        private CaseInsensitiveComparer2(){}

        public bool Equals(string x, string y) {
            return x.Equals(y, StringComparison.OrdinalIgnoreCase);
        }
        public int GetHashCode(string obj) {
            return obj.ToLowerInvariant().GetHashCode();
        }
    }
}